package com.sakura.oj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sakura.oj.model.dto.solution.SolutionQueryRequest;
import com.sakura.oj.model.entity.ProblemSolution;
import com.sakura.oj.model.vo.ProblemSolutionVo;
import com.sakura.oj.model.vo.RecentlySolutionVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Sakura
 * @description 针对表【problem_solution(题目题解表)】的数据库操作Mapper
 * @createDate 2025-03-19 20:38:14
 * @Entity generator.domain.ProblemSolution
 */
public interface ProblemSolutionMapper extends BaseMapper<ProblemSolution> {

    /**
     * 分页查询题解
     *
     * @param page                 分页
     * @param solutionQueryRequest 查询条件
     * @return 分页
     */
    Page<ProblemSolutionVo> listProblemSolutionVoByPage(@Param("page") Page<ProblemSolutionVo> page, @Param("query") SolutionQueryRequest solutionQueryRequest);

    @Select("SELECT id, title, views FROM problem_solution WHERE user_id = #{userId} ORDER BY update_time DESC LIMIT 5")
    List<RecentlySolutionVo> getRecentlySolutionList(Long userId);
}




